<?php

/**
 * 日志写入测试
 */

namespace console\controllers;

use yii\console\Controller;
use common\logic\logs\Log;
use common\logic\logs\FLogHandler;
use common\logic\logs\DLogHandler;

class LoggerController extends Controller{
    
    /**
     * 文件记录
     * @return
     * @author syy
     * @date 2021-02-18 下午4:39
     */
    public function actionFileLogs(){
        //初始化日志
        $logHandler= new FLogHandler(__DIR__."/../runtime/logs/".date('Y-m-d').'.log');
        Log::Init($logHandler, 15, 1);
        Log::Error("Error");
    }
    
    
    /**
     * 日志写入数据库
     * @return
     * @author syy
     * @date 2021-02-18 下午4:39
     */
    public function actionDLogs(){
        //初始化日志
        $logHandler= new DLogHandler();
        Log::Init($logHandler, 15, 2);
        $msg['id'] = 1;
        $msg['level'] = 4;
        Log::Warning($msg);
    }
}